package threadings;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: yyx
 * Date: 2024-02-03
 * Time: 16:29
 */
public class ThreadDemo11 {
    public static void main(String[] args) throws InterruptedException {
        Object obj = new Object();
        Thread t1 = new Thread(()->{
            System.out.println("wait之前");
            synchronized (obj){
                try {
                    obj.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("wait之后");
        });

        t1.start();
        Thread.sleep(1000);

        Thread t2 = new Thread(()->{
            System.out.println("notify之前");
            synchronized (obj){
                obj.notify();
            }
            System.out.println("notify之后");
        });
        t2.start();
    }
}
